/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model YxTestSingleHsfApiRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model YxTestSingleHsfApiResponseBody = {
  sum?: int32(name='sum'),
}

model YxTestSingleHsfApiResponse = {
  headers: map[string]string(name='headers'),
  body: YxTestSingleHsfApiResponseBody(name='body'),
}

async function yxTestSingleHsfApiWithOptions(request: YxTestSingleHsfApiRequest, runtime: Util.RuntimeOptions): YxTestSingleHsfApiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('YxTestSingleHsfApi', '2021-07-13_20-44-22-439', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function yxTestSingleHsfApi(request: YxTestSingleHsfApiRequest): YxTestSingleHsfApiResponse {
  var runtime = new Util.RuntimeOptions{};
  return yxTestSingleHsfApiWithOptions(request, runtime);
}

model SubstractRequest {
  a?: int32(name='a'),
  b?: int32(name='b'),
}

model SubstractResponse = {
  headers: map[string]string(name='headers'),
  body: int32(name='body'),
}

async function substractWithOptions(request: SubstractRequest, runtime: Util.RuntimeOptions): SubstractResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('Substract', '2021-07-13_20-44-22-439', 'HTTPS', 'POST', 'AK', 'int32', req, runtime);
}

async function substract(request: SubstractRequest): SubstractResponse {
  var runtime = new Util.RuntimeOptions{};
  return substractWithOptions(request, runtime);
}

model AddRequest {
  a?: int32(name='a'),
  b?: int32(name='b'),
}

model AddResponse = {
  headers: map[string]string(name='headers'),
  body: int32(name='body'),
}

async function addWithOptions(request: AddRequest, runtime: Util.RuntimeOptions): AddResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('Add', '2021-07-13_20-44-22-439', 'HTTPS', 'POST', 'AK', 'int32', req, runtime);
}

async function add(request: AddRequest): AddResponse {
  var runtime = new Util.RuntimeOptions{};
  return addWithOptions(request, runtime);
}

model YxTestSingleNbfApiRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model YxTestSingleNbfApiResponseBody = {
  sum?: int32(name='sum'),
}

model YxTestSingleNbfApiResponse = {
  headers: map[string]string(name='headers'),
  body: YxTestSingleNbfApiResponseBody(name='body'),
}

async function yxTestSingleNbfApiWithOptions(request: YxTestSingleNbfApiRequest, runtime: Util.RuntimeOptions): YxTestSingleNbfApiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('YxTestSingleNbfApi', '2021-07-13_20-44-22-439', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function yxTestSingleNbfApi(request: YxTestSingleNbfApiRequest): YxTestSingleNbfApiResponse {
  var runtime = new Util.RuntimeOptions{};
  return yxTestSingleNbfApiWithOptions(request, runtime);
}

model SayNameRequest {
  name?: string(name='name'),
}

model SayNameResponse = {
  headers: map[string]string(name='headers'),
  body: string(name='body'),
}

async function sayNameWithOptions(request: SayNameRequest, runtime: Util.RuntimeOptions): SayNameResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('SayName', '2021-07-13_20-44-22-439', 'HTTPS', 'POST', 'AK', 'string', req, runtime);
}

async function sayName(request: SayNameRequest): SayNameResponse {
  var runtime = new Util.RuntimeOptions{};
  return sayNameWithOptions(request, runtime);
}

